from manim import *


class scale(Scene):
    """
    缩放
    """

    def construct(self):
        square = Square(color=BLUE, fill_opacity=0.8)  # 方形
        # self.play(Scale(square,2)) -->NG
        self.play(square.animate.scale(0.5))
        self.play(square.animate.scale(2.0))


class UnevenScale(Scene):
    """
    沿x,y轴方向缩放
    """

    def construct(self):
        square = Square(color=BLUE, fill_opacity=0.5)
        self.play(Create(square))

        # 水平拉伸
        self.play(square.animate.stretch(2, dim=0))  # dim=0表示x轴

        # 垂直压缩
        self.play(square.animate.stretch(0.5, dim=1))  # dim=1表示y轴
        self.wait()
